package com.yujinglin.AirClassify;



import com.yujinglin.util.testJson;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class AirCLassDriver {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {

        //1 获取job
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
//        job.setInputFormatClass();

        job.setJarByClass(AirCLassDriver.class);

        job.setMapperClass(AirClassifyMapper.class);
        job.setReducerClass(AirClassifyReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        FileInputFormat.setInputPaths(job,new Path("/data/flights.csv"));
        FileOutputFormat.setOutputPath(job,new Path("/home/niit/Output1"));


        boolean result = job.waitForCompletion(true);
        testJson.readFromHdfs("hdfs://niit-master:9000/home/niit/Output1/part-r-00000");

//        FileInputFormat.setInputPaths(job,new Path("C:/Users/hanyiyang/Desktop/flights.csv"));
//        FileOutputFormat.setOutputPath(job,new Path("src/main/java/input/outputYu/Output1"));
//
//
//        boolean result = job.waitForCompletion(true);
//        testJson.readFromHdfs("hdfs://niit-master:9000/home/niit/Output1/part-r-00000");
        System.exit(result ? 0 : 1);
    }
}
